﻿namespace Microsoft.Coding4Fun.TweetCraft.Twitter
{
    /// <summary>
    /// Provides an abstract base class to convert Twitter user pictures to other formats.
    /// </summary>
    public abstract class UserPictureConverter
    {
        private readonly int destinationWidth;
        private readonly int destinationHeight;
        private readonly int enlargedDestinationWidth;
        private readonly int enlargedDestinationHeight;

        /// <summary>
        /// Initializes a new instance of the <see cref="UserPictureConverter"/> class.
        /// </summary>
        /// <param name="destinationWidth">Width of the destination file.</param>
        /// <param name="destinationHeight">Height of the destination. file</param>
        /// <param name="enlargedDestinationWidth">Width of the enlarged destination.</param>
        /// <param name="enlargedDestinationHeight">Height of the enlarged destination.</param>
        protected UserPictureConverter(int destinationWidth, int destinationHeight, int enlargedDestinationWidth, int enlargedDestinationHeight)
        {
            this.destinationWidth = destinationWidth;
            this.destinationHeight = destinationHeight;
            this.enlargedDestinationWidth = enlargedDestinationWidth;
            this.enlargedDestinationHeight = enlargedDestinationHeight;
        }

        protected UserPictureConverter(int destinationWidth, int destinationHeight)
            : this(destinationWidth, destinationHeight, destinationWidth, destinationHeight)
        {
        }

        protected int DestinationWidth
        {
            get { return destinationWidth; }
        }

        protected int DestinationHeight
        {
            get { return destinationHeight; }
        }

        protected int EnlargedDestinationWidth
        {
            get { return enlargedDestinationWidth; }
        }

        protected int EnlargedDestinationHeight
        {
            get { return enlargedDestinationHeight; }
        }

        /// <summary>
        /// Converts a Twitter user picture to another format and size.
        /// </summary>
        /// <param name="source">The path to the source file.</param>
        /// <param name="destination">The path to the destination file.</param>
        /// <returns>True, if the conversion was successful; false otherwise.</returns>
        public abstract bool Convert(string source, string destination);
    }
}